package org.dl.gjz.menyj.task.listener;

import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.ExecutionListener;
import org.springframework.stereotype.Service;

@Service("gatewayParallelStartListener")
public class GatewayParallelStartListener implements ExecutionListener {
    @Override
    public void notify(DelegateExecution execution) throws Exception {
        System.out.println("GatewayParallelStartListener start");

        System.out.println("ProcessInstanceId: " + execution.getProcessInstanceId());
        System.out.println("ProcessBusinessKey: " + execution.getProcessBusinessKey());
        System.out.println("ProcessDefinitionId: " + execution.getProcessDefinitionId());

        System.out.println("CurrentActivityId: " + execution.getCurrentActivityId());
        System.out.println("CurrentActivityName: " + execution.getCurrentActivityName());

        System.out.println("ActivityInstanceId: " + execution.getActivityInstanceId());// 节点实例Id
        System.out.println("ParentActivityInstanceId: " + execution.getParentActivityInstanceId());

        RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();
        runtimeService.setVariable(execution.getProcessInstanceId(),"checkman1", "demo");
        runtimeService.setVariable(execution.getProcessInstanceId(),"checkman2", "xiaowang");
    }
}
